<template>
  <div class="dialog-container">
    <el-dialog :title="dialogTitle" :visible.sync="dialogVisible" :width="dialogWidth" :close-on-click-modal="false"
     :top="marginTop" :custom-class="customClass" @close="close()" @closed="closed">
      <!--  width="30%" -->
      <div class="title-box" v-if="showCenter">
        <div class="title">
          <div class="left-line"></div>
          <div class="center-title">{{ centerTitle }}</div>
          <div class="right-line"></div>
        </div>
      </div>
      <div class="content">
        <slot name="content"></slot>
      </div>

      <div class="footer">
        <slot :name="footerName">
          <template :v-slot="footerName"></template>
        </slot>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: {
    footerName: {
      default: "footer"
    },
    dialogTitle: {
      default: "详情"
    },
    centerTitle: {
      default: "添加"
    },
    showCenter: {
      type: Boolean,
      default: true
    },
    dialogWidth: {
      default: "50%"
    }
  },
  data () {
    return {
      dialogVisible: false,
      customClass: "",
      isBig: true,
      marginTop: "10vh"
    }
  },
  created () {
    this.customClass = ""
  },
  methods: {
    close () {
      this.$emit("close")
    },
    closed () {
      this.isBig = true
      this.customClass = ""
      this.marginTop = "15vh"
    },
  }
}
</script>

<style lang="scss" scoped>
.dialog-container {
  ::v-deep .el-dialog {
    display: flex;
    flex-direction: column;
    border-radius: 8px;

    .el-dialog__headerbtn {
      // 叉号样式
      font-size: 30px;
    }

    .el-dialog__header {
      background: #024c57;
      border-bottom: 1px solid #024c57;
      border-radius: 8px 8px 0 0;
      overflow: hidden;

      .el-dialog__title {
        color: #5cdbe5;
      }

      .el-dialog__close {
        color: #5cdbe5;
      }
    }

    .el-dialog__body {
      flex: 1;
      display: flex;
      flex-direction: column;
      background: #0B333C;
    }

    .el-dialog__headerbtn {
      font-size: 20px;
    }
  }

  ::v-deep .myCustomClass {
    position: absolute;
    left: 210px;
    width: calc(100vw - 210px) !important;
    /*height: calc(100vh - 100px) !important;*/
  }

  .title-box {
    display: flex;
    justify-content: center;

    .title {
      width: 620px;
      // border: 1px solid red;
      height: 25px;
      display: flex;
      align-items: center;
      justify-content: space-around;

      .left-line {
        height: 1px;
        width: 220px;
        background: #bebebe;
      }

      .center-title {
        font-weight: 400;
        font-size: 20px;
        color: #000000;
      }

      .right-line {
        height: 1px;
        width: 220px;
        background: #bebebe;
      }
    }
  }

  .content {
    /*padding: 10px;*/
    flex: 1;
  }

  ::v-deep .footer {
    display: flex;
    justify-content: center;

    .el-button {
      width: 92px;
      height: 36px;
      background: #024c57;
      color: #5cdbe5;
      border: none;
      border-radius: 2px;
    }
  }
}</style>
